package GUI;


import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JPanel;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;

import client.ClientConsole;

import java.awt.Font;

/**this class display catalog options to choose from*/
public class GUI_Catalog extends JPanel
{
	/**ab instance of GUI_AddBook*/
	private GUI_AddBook ab;
	/**delB instance of GUI_DeleteBook*/
	private GUI_DeleteBook delB;
	/**ac instance of GUI_AddCopy*/
	private GUI_AddCopy ac;
	/**dc instance of GUI_DeleteCopy*/
	private GUI_DeleteCopy dc;
	/**clc instance of ClientConsole*/
	private ClientConsole clc;
	/**gc instance of current GUI_Catalog*/
	private static GUI_Catalog gc;
	/**gl instance of current GUI_LogIn*/
	private GUI_LogIn gl;
	/**backPanel panel to return to*/
	private JPanel backPanel;
	
	/**@param cc current ClientConsole
	 * @param gl instance of current GUI_LogIn
	 * @param lm instance of current GUI_LibrarianMenu*/
	public GUI_Catalog(ClientConsole cc,final GUI_LogIn gl,final GUI_LibrarianMenu lm)
	{
		clc=cc;
		gc=this;
		this.gl=gl;
		backPanel=lm;
		same();
	}
	
	/**@param cc current ClientConsole
	 * @param gl instance of current GUI_LogIn
	 * @param mm instance of current GUI_ManagerMenu*/
	public GUI_Catalog(ClientConsole cc,final GUI_LogIn gl,final GUI_ManagerMenu mm)
	{
		clc=cc;
		gc=this;
		this.gl=gl;
		backPanel=mm;
		same();
	}
	
	/**this method display catalog options to choose from*/
	public void same()
	{
		this.setSize(700, 600);
		setName("Catalog");
		setLayout(null);
		JButton btnAddBook = new JButton("Add Book");
		btnAddBook.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				ab=new GUI_AddBook(clc,gl,gc);
				gl.setContentPane(ab);
			}
		});
		btnAddBook.setBounds(73, 102, 153, 23);
		add(btnAddBook);
		JButton btnDeleteBook = new JButton("Delete Book");
		btnDeleteBook.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				//delB=GUI_DeleteBook.instance(clc,gl,gc);
				delB=new GUI_DeleteBook(clc,gl,gc);
				gl.setContentPane(delB);
			}
		});
		btnDeleteBook.setBounds(73, 177, 153, 23);
		add(btnDeleteBook);
		
		JButton btnAddCopy = new JButton("Add Copy");
		btnAddCopy.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				ac=new GUI_AddCopy(clc, gl, gc);
				gl.setContentPane(ac);
			}
		});
		btnAddCopy.setBounds(73, 246, 153, 23);
		add(btnAddCopy);
		
		JButton btnDeleteCopy = new JButton("Delete Copy");
		btnDeleteCopy.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dc=new GUI_DeleteCopy(clc,gl,gc);
				gl.setContentPane(dc);
			}
		});
		btnDeleteCopy.setBounds(73, 310, 153, 23);
		add(btnDeleteCopy);
		
		JButton btnBack = new JButton("Back");
		btnBack.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				gl.setContentPane(backPanel);
			}
		});
		btnBack.setBounds(380, 333, 89, 23);
		add(btnBack);
		
		JButton btnLogOut = new JButton("Log Out");
		btnLogOut.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				gl.LogOut();
			}
		});
		btnLogOut.setBounds(492, 333, 89, 23);
		add(btnLogOut);
		
		JLabel lblPleaseChooseOne = new JLabel("Please choose one of the options:");
		lblPleaseChooseOne.setFont(new Font("Tahoma", Font.BOLD, 13));
		lblPleaseChooseOne.setBounds(73, 33, 254, 23);
		add(lblPleaseChooseOne);
		setVisible(true);
	}
}
